package com.fortune.service.impl;

import com.fortune.dao.COrderDao;
import com.fortune.entity.COrderPolicy;
import com.fortune.service.COrderService;
import com.fortune.vo.cOrder.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

@Service
public class COrderServiceImpl implements COrderService {
    @Autowired
    private COrderDao cOrderDao;

    /**
     * 查询商品列表
     * @param mid
     * @return
     */
    @Override
    public List<ClientOrderProduct> findListOrderProductInfo(String mid) {
        List<ClientOrderProduct> findListOrderProductInfo = cOrderDao.findListOrderProductInfo(mid);
        return findListOrderProductInfo;
    }

    /**
     * 查询商品优惠
     * @param mid
     * @param mpid
     * @return
     */
    @Override
    public COrderPolicy findListCOrderPolicy(String mid, String mpid) {
        COrderPolicy findListCOrderPolicy = cOrderDao.findListCOrderPolicy(mid, mpid);
        return findListCOrderPolicy;
    }

    /**
     * 生成订单
     * @param mid
     * @param did
     * @param clientId
     * @param id
     * @param no
     * @param userId
     * @param pTotalPrice
     * @param dTotalPrice
     * @return
     */
    @Override
    public int addCOrder(String mid, String did, String clientId, String id, String no, String userId, BigDecimal pTotalPrice, BigDecimal dTotalPrice) {
        int addCOrder = cOrderDao.addCOrder(mid, did, clientId, id, no, userId, pTotalPrice, dTotalPrice);
        return addCOrder;
    }

    /**
     * 添加订单详情
     * @param mid
     * @param did
     * @param clientId
     * @param id
     * @param detailsNo
     * @param productId
     * @param orderNum
     * @param price
     * @param policyId
     * @param unitPrice
     * @param backBoxNum
     * @param dprice
     * @param tprice
     * @return
     */
    @Override
    public int addCOrderDetails(String mid, String did, String clientId, String id, int detailsNo, String productId, float orderNum, BigDecimal price, String policyId, BigDecimal unitPrice, float backBoxNum, BigDecimal dprice, BigDecimal tprice) {
        int addCOrderDetails = cOrderDao.addCOrderDetails(mid, did, clientId, id, detailsNo, productId, orderNum, price, policyId, unitPrice, backBoxNum, dprice, tprice);
        return addCOrderDetails;
    }

    /**
     * 添加订单详情-赠送
     * @param mid
     * @param did
     * @param clientId
     * @param id
     * @param detailsNo
     * @param productId
     * @param orderNum
     * @param price
     * @param policyId
     * @param unitPrice
     * @param backBoxNum
     * @param dprice
     * @param tprice
     * @return
     */
    @Override
    public int addCOrderDetailsByZS(String mid, String did, String clientId, String id, int detailsNo, String productId, float orderNum, BigDecimal price, String policyId, BigDecimal unitPrice, float backBoxNum, BigDecimal dprice, BigDecimal tprice) {
        int addCOrderDetailsByZS = cOrderDao.addCOrderDetailsByZS(mid, did, clientId, id, detailsNo, productId, orderNum, price, policyId, unitPrice, backBoxNum, dprice, tprice);
        return addCOrderDetailsByZS;
    }

    /**
     * 删除订单
     * @param mid
     * @param did
     * @param clientId
     * @param ordersId
     * @param ordersNums
     * @return
     */
    @Override
    public int editOrder(String mid, String did, String clientId, String ordersId, String ordersNums) {
        int editOrder = cOrderDao.editOrder(mid, did, clientId, ordersId, ordersNums);
        return editOrder;
    }

    /**
     * 订单详情
     * @param mid
     * @param did
     * @param clientId
     * @param orderId
     * @return
     */
    @Override
    public ClientOrderDetail findClientOrderDetail(String mid, String did, String clientId, String orderId) {
        ClientOrderDetail findClientOrderDetail = cOrderDao.findClientOrderDetail(mid, did, clientId, orderId);
        return findClientOrderDetail;
    }

    /**
     * 已出库订单详情
     * @param mid
     * @param did
     * @param clientId
     * @param orderId
     * @return
     */
    @Override
    public ClientOrderDetail findClientOrderDetailByCk(String mid, String did, String clientId, String orderId) {
        ClientOrderDetail findClientOrderDetailByCk = cOrderDao.findClientOrderDetailByCk(mid, did, clientId, orderId);
        return findClientOrderDetailByCk;
    }

    /**
     * 已收货订单详情
     * @param mid
     * @param did
     * @param clientId
     * @param orderId
     * @return
     */
    @Override
    public ClientOrderDetails findClientOrderDetailsBySH(String mid, String did, String clientId, String orderId) {
        ClientOrderDetails findClientOrderDetailsBySH = cOrderDao.findClientOrderDetailsBySH(mid, did, clientId, orderId);
        return findClientOrderDetailsBySH;
    }

    /**
     * 已完成订单详情
     * @param mid
     * @param did
     * @param clientId
     * @param orderId
     * @return
     */
    @Override
    public ClientOrderDetails findClientOrderDetailsByWC(String mid, String did, String clientId, String orderId) {
        ClientOrderDetails findClientOrderDetailsByWC = cOrderDao.findClientOrderDetailsByWC(mid, did, clientId, orderId);
        return findClientOrderDetailsByWC;
    }

    /**
     * 删除订单
     * @param mid
     * @param did
     * @param clientId
     * @param orderId
     * @return
     */
    @Override
    public int deleteCOrder(String mid, String did, String clientId, String orderId) {
        int deleteCOrder = cOrderDao.deleteCOrder(mid, did, clientId, orderId);
        return deleteCOrder;
    }

    /**
     * 查询未处理的列表
     * @param mid
     * @param did
     * @param userId
     * @return
     */
    @Override
    public List<ClientOrder> findListClientOrder(String mid, String did, String userId) {
        List<ClientOrder> findListClientOrder = cOrderDao.findListClientOrder(mid, did, userId);
        return findListClientOrder;
    }

    /**
     * 查询已批准的列表
     * @param mid
     * @param did
     * @param userId
     * @return
     */
    @Override
    public List<ClientOrder> findListClientOrderByApproved(String mid, String did, String userId) {
        List<ClientOrder> findListClientOrderByApproved = cOrderDao.findListClientOrderByApproved(mid, did, userId);
        return findListClientOrderByApproved;
    }

    /**
     * 查询已发货的列表
     * @param mid
     * @param did
     * @param userId
     * @return
     */
    @Override
    public List<ClientOrder> findListClientOrderByShipped(String mid, String did, String userId) {
        List<ClientOrder> findListClientOrderByShipped = cOrderDao.findListClientOrderByShipped(mid, did, userId);
        return findListClientOrderByShipped;
    }

    /**
     * 查询已收货
     * @param mid
     * @param did
     * @param userId
     * @return
     */
    @Override
    public List<ClientOrder> findListClientOrderByreceived(String mid, String did, String userId) {
        List<ClientOrder> findListClientOrderByreceived = cOrderDao.findListClientOrderByreceived(mid, did, userId);
        return findListClientOrderByreceived;
    }

    /**
     * 查询已完成的列表
     * @param mid
     * @param did
     * @param userId
     * @return
     */
    @Override
    public List<ClientOrder> findListClientOrderByCompleted(String mid, String did, String userId) {
        List<ClientOrder> findListClientOrderByCompleted = cOrderDao.findListClientOrderByCompleted(mid, did, userId);
        return findListClientOrderByCompleted;
    }
}
